package me.zhengjie.ppService;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import me.zhengjie.pojo.sqlServer.PPTaskResult;
import me.zhengjie.repository.PPTaskResultRepository;
import org.springframework.stereotype.Component;

/**
 * @Author: xinglin
 * @CreateTime: 2024-08-15
 * @Description: 任务结果管理
 * @Version: 1.0
 */


@Slf4j
@Component
@RequiredArgsConstructor
public class PPTaskResultService {

    //声明PPTaskResultRepository类型的变量ppTaskResultRepository，并且不可更改
    private final PPTaskResultRepository ppTaskResultRepository;

    //根据任务类型查找当前的PPTaskResult
    public PPTaskResult findNowppTaskResult(Integer taskType) {
        return ppTaskResultRepository.findPPTaskResultByWcsTaskType(taskType);
    }

    //根据任务类型删除PPTaskResult
    public int deleteByWcsTaskType(Integer taskType) {
        return ppTaskResultRepository.deleteByWcsTaskType(taskType);
    }

    //根据任务ID删除PPTaskResult
    public int deleteByWmsTaskId(String taskId) {
        return ppTaskResultRepository.deletePPTaskResultByWmsTaskId(taskId);
    }

    //保存PPTaskResult
    public void saveTaskResult(PPTaskResult taskResult) {
        ppTaskResultRepository.saveAndFlush(taskResult);
    }


}




